//
//  Apputil.h
//  DaDaImage-iPad2.0
//
//  Created by dengchunhua on 16/7/1.
//  Copyright © 2016年 iinda.com. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>


typedef enum {
    MBImageSize70x70 ,
    MBImageSize160x160,// = 1,
    MBImageSize240x240,// = 2,
    MBImageSize500x0,// = 3,
    MBImageSize640x0,// = 4
    MBImageSize640x640,// = 5
    MBImageSize640x480,// = 5
    MBImageSize50x50,// = 5
} MBImageSizeCode;

@interface Apputil : NSObject

/**
 *  国际化(根据key获取字符串)
 */
+(NSString*)LocalizedString:(NSString*)str;
/**
 *  提示消息
 *
 *  @param message 消息文本
 *  @param time    提示框消失间隔时间
 */
+ (void)showMessage:(NSString *)message afterDelay:(NSTimeInterval)time;
/**
 *  提示错误信息
 *
 *  @param errorMessage 错误描述
 */
+ (void)showError:(id)errorMessage;
/**
 *  提示信息，不会自动关闭提示框
 *
 *  @param message 提示信息(nil的时候默认提示  "加载中，请稍后。。。")
 */
+ (void)showMessage:(NSString*) message;

+ (void)dismiss;

/**
 *  添加全局配置
 *
 *  @param obj 属性
 *  @param key 属性KEY
 */
+(void)NSUserDefAddString:(NSString *) obj key:(NSString *) key;
+(void)NSUserDefAddOject:(id)obj key:(NSString *)key;
/**
 *  获取指定的全局配置属性
 *
 *  @param key 传入key
 *
 *  @return 返回指定key的全局属性
 */
+(id) QueryNSUserDefToKey:(NSString *)key;



/**
 *  发布service通知
 *
 *  @param notifiDict 请求需要的数据源
 *  @param name      通知名称
 */
//+(void)ReleaseServiceNotice:(NSDictionary*) notifiDict noticeName:(NSString*) name;

/**
 *  验证邮箱
 *
 *  @param emailStr 传入emailStr
 *
 *  @return 返回YES邮箱正确，否则邮箱格式不正确
 */
+ (BOOL)validateEmailString:(NSString *)emailStr;

/**
 *  验证电话号码格式
 *
 *  @param phoneNumber 传入电话号码
 *
 *  @return 返回YES号码格式正确，否则不正确
 */
+ (BOOL)validatePhoneWithString:(NSString *)phoneNumber;


//url不能包含ASSIC码,需要转换
+ (NSString *)getconvertUrlStr:(NSString *)originUrlStr;

//获取本地文件路径（用于判断本地是否已经存在）
+ (NSString *)getfilePathWithUrlStr:(NSString *)urlStr;
+ (NSString *)getfilePathWithUrlStr:(NSString *)urlStr docname:(NSString *)docname;

+(NSString *)distanceWithMetre:(long)metre;

+(NSURL *)getUrlByImagePath:(NSString *)path size:(MBImageSizeCode)size;

+ (void)showView:(UIView *)view center:(CGPoint)point frame:(CGRect)rect completion:(void (^)(BOOL bSuccess))completion;

+ (void)dismissView:(UIView *)view center:(CGPoint)point completion:(void (^)(BOOL bSuccess))completion;
+(UIViewController *)dch_viewControllerOfView:(UIView *)theView;

//获取时间差
+ (NSString *)getTime:(NSString *)datestr;

//判断是否有中文字符
+ (BOOL)hasChinese:(NSString *)str;

////获取日期时间中的 日
//+ (NSString *)getDayWithDateStr:(NSString *)datestr;
////获取日期时间中的 时分
//+ (NSString *)getTimeWithDateStr:(NSString *)datestr;
////获取日期时间中的 年月日
//+ (NSString *)getDateWithDateStr:(NSString *)datestr;


+ (double)bdlon:(double)gg_lat gg_lon:(double)gg_lon;
+ (double)bdlat:(double)gg_lat gg_lon:(double)gg_lon;


+ (CGFloat)textHeight:(NSString *)s font:(UIFont*)font textWidth:(CGFloat)width;
+ (CGFloat)textWidth:(NSString *)s font:(UIFont*)font textHeight:(CGFloat)height;

+ (CGFloat)textHeight:(NSString *)s fontName:(NSString*)fontName fontSize:(NSInteger)fsize textWidth:(CGFloat)width;
+ (CGFloat)textWidth:(NSString *)s fontName:(NSString*)fontName fontSize:(NSInteger)fsize textHeight:(CGFloat)height;
+(NSString *)replaceStringWithAsterisk:(NSString *)originalStr startLocation:(NSInteger)startLocation lenght:(NSInteger)lenght;

@end
